/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "ESTUDIOPERSONA", catalog = "", schema = "PROYECTO")
@NamedQueries({
    @NamedQuery(name = "Estudiopersona.findAll", query = "SELECT e FROM Estudiopersona e"),
    @NamedQuery(name = "Estudiopersona.findByPersonaCodigopersona", query = "SELECT e FROM Estudiopersona e WHERE e.estudiopersonaPK.personaCodigopersona = :personaCodigopersona"),
    @NamedQuery(name = "Estudiopersona.findByEstudiosCodigo", query = "SELECT e FROM Estudiopersona e WHERE e.estudiopersonaPK.estudiosCodigo = :estudiosCodigo"),
    @NamedQuery(name = "Estudiopersona.findByFechagraduacion", query = "SELECT e FROM Estudiopersona e WHERE e.fechagraduacion = :fechagraduacion")})
public class Estudiopersona implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected EstudiopersonaPK estudiopersonaPK;
    @Column(name = "FECHAGRADUACION")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechagraduacion;
    @JoinColumn(name = "PERSONA_CODIGOPERSONA", referencedColumnName = "CODIGOPERSONA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Persona persona;
    @JoinColumn(name = "ESTUDIOS_CODIGO", referencedColumnName = "CODIGO", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Estudios estudios;

    public Estudiopersona() {
    }

    public Estudiopersona(EstudiopersonaPK estudiopersonaPK) {
        this.estudiopersonaPK = estudiopersonaPK;
    }

    public Estudiopersona(int personaCodigopersona, int estudiosCodigo) {
        this.estudiopersonaPK = new EstudiopersonaPK(personaCodigopersona, estudiosCodigo);
    }

    public EstudiopersonaPK getEstudiopersonaPK() {
        return estudiopersonaPK;
    }

    public void setEstudiopersonaPK(EstudiopersonaPK estudiopersonaPK) {
        this.estudiopersonaPK = estudiopersonaPK;
    }

    public Date getFechagraduacion() {
        return fechagraduacion;
    }

    public void setFechagraduacion(Date fechagraduacion) {
        this.fechagraduacion = fechagraduacion;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    public Estudios getEstudios() {
        return estudios;
    }

    public void setEstudios(Estudios estudios) {
        this.estudios = estudios;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (estudiopersonaPK != null ? estudiopersonaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Estudiopersona)) {
            return false;
        }
        Estudiopersona other = (Estudiopersona) object;
        if ((this.estudiopersonaPK == null && other.estudiopersonaPK != null) || (this.estudiopersonaPK != null && !this.estudiopersonaPK.equals(other.estudiopersonaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Estudiopersona[estudiopersonaPK=" + estudiopersonaPK + "]";
    }

}
